package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.vo.ListOfWinnersVO;
import com.sc.nft.entity.vo.LotteryDataPageVO;
import com.sc.nft.entity.vo.MyListWinnersVO;
import com.sc.nft.enums.PrizeDrawActivitySettleStatisEnum;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.PrizeDrawActivitySettleRecords;
import com.sc.nft.mapper.PrizeDrawActivitySettleRecordsMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 抽奖活动结算记录表(sc_prize_draw_activity_settle_records)数据DAO
 *
 * @author Sun
 * @since 2023-09-14 11:32:52
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class PrizeDrawActivitySettleRecordsDao extends ServiceImpl<PrizeDrawActivitySettleRecordsMapper, PrizeDrawActivitySettleRecords> {

    public List<MyListWinnersVO> myListWinners(Long activityId, Long userId) {
        return baseMapper.myListWinners(activityId,userId);
    }

    public List<ListOfWinnersVO> listOfWinners(Long activityId) {
        return baseMapper.listOfWinners(activityId);
    }

    public IPage<LotteryDataPageVO> guessLotteryDataPageByActivityId(Page page, Long activityId,String userTel,String lotteryDrawResultVar,String typeName) {
        return baseMapper.guessLotteryDataPageByActivityId(page,activityId,userTel,lotteryDrawResultVar,typeName);
    }

    public IPage<LotteryDataPageVO> carveUpLotteryDataPageByActivityId( Page page,Long activityId,String userTel,String lotteryDrawResultVar,String typeName) {
        return baseMapper.carveUpLotteryDataPageByActivityId(page,activityId,userTel,lotteryDrawResultVar,typeName);
    }

    public boolean updateRewardsStatusById(Long id, PrizeDrawActivitySettleStatisEnum status) {
        LambdaUpdateWrapper<PrizeDrawActivitySettleRecords> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(PrizeDrawActivitySettleRecords::getId,id);
        wrapper.set(PrizeDrawActivitySettleRecords::getStatus,status);
        return update(new PrizeDrawActivitySettleRecords(),wrapper);
    }

    public List<PrizeDrawActivitySettleRecords> getListByIsSettleAndStatus() {
        return baseMapper.getListByIsSettleAndStatus();
    }

    public boolean updateIsSettleAndStatusById(Long id) {
        LambdaUpdateWrapper<PrizeDrawActivitySettleRecords> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(PrizeDrawActivitySettleRecords::getId,id);
        wrapper.set(PrizeDrawActivitySettleRecords::getIsSettle,Boolean.TRUE);
        wrapper.set(PrizeDrawActivitySettleRecords::getStatus,PrizeDrawActivitySettleStatisEnum.ISSUED);
        return update(wrapper);
    }
}